/* eslint-disable max-params */
import { initDeviceId, getLocalStorage, setLocalStorage } from './utils';
class Reporter {
	constructor() {
		this.deviceId = this.getDeviceId();

		window.addEventListener('load', () => {
			this.report('default', 'onLoad', {});
		});

		window.addEventListener(
			'error',
			(message, url, line, column, error) => {
				this.report('default', 'onError', {
					message,
					url,
					line,
					column,
					error,
				});
			}
		);
	}

	getDeviceId() {
		const storagId = getLocalStorage('wf-device-id');
		if (!storagId) {
			const d = initDeviceId();
			setLocalStorage('wf-device-id', d);
			return d;
		}
		return storagId;
	}

	report(type = 'default', name = '', payload = {}) {
		// const cloudApi = wf.getModule('cloudApi');
		return false;
		// return cloudApi.weblogReport(type, name, payload);
	}
}

export default Reporter;
